<?php

namespace App\Http\Controllers\Api\JuheH5;

use App\Http\Controllers\Controller;
use App\Services\JuheH5\AccountService;
use Illuminate\Http\Request;

class AccountController extends Controller
{
    /**
     * 快速注册
     */
    public function fastReg(Request $request)
    {
        $game_id = $request->input('game_id');
        $res = AccountService::getInstance()->fastReg($game_id);
        if (!$res) {
            return yqerr(9999);
        }

        return yqok($res);
    }

    /**
     * 手机注册
     */
    public function phoneReg(Request $request)
    {
        $res = AccountService::getInstance()->phoneReg($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 账号注册
     */
    public function accountReg(Request $request)
    {
        $res = AccountService::getInstance()->accountReg($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 手机登录
     */
    public function phoneLogin(Request $request)
    {
        $res = AccountService::getInstance()->phoneLogin($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 账号登录
     */
    public function accountLogin(Request $request)
    {
        $res = AccountService::getInstance()->accountLogin($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 令牌登录
     */
    public function tokenLogin(Request $request)
    {
        $res = AccountService::getInstance()->tokenLogin($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 实名认证
     */
    public function idcardAuthenticate(Request $request)
    {
        $res = AccountService::getInstance()->idcardAuthenticate($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 绑定手机
     */
    public function phoneBind(Request $request)
    {
        $res = AccountService::getInstance()->phoneBind($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 解绑手机
     */
    public function phoneUnbind(Request $request)
    {
        $res = AccountService::getInstance()->phoneUnbind($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }

    /**
     * 找回密码
     */
    public function passwordRetrieve(Request $request)
    {
        $res = AccountService::getInstance()->passwordRetrieve($request->all());
        if (!is_array($res)) {
            return yqerr($res);
        }

        return yqok($res);
    }
}
